package com.binance.notification.web.push.notification;

import java.util.Map;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;

import cn.jpush.api.push.model.notification.PlatformNotification;

public class PcNotification extends PlatformNotification {
    public static final String NOTIFICATION_WINDOWS = "windows";

    private static final String TITLE = "title";

    private final String title;

    private PcNotification(Object alert, String title, Map<String, String> extras, Map<String, Number> numberExtras,
            Map<String, Boolean> booleanExtras, Map<String, JsonObject> jsonExtras) {
        super(alert, extras, numberExtras, booleanExtras, jsonExtras);
        this.title = title;
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public static PcNotification alert(String alert) {
        return newBuilder().setAlert(alert).build();
    }


    @Override
    public String getPlatform() {
        return NOTIFICATION_WINDOWS;
    }

    @Override
    public JsonElement toJSON() {
        JsonObject json = super.toJSON().getAsJsonObject();
        if (null != title) {
            json.add(TITLE, new JsonPrimitive(title));
        }
        return json;
    }


    public static class Builder extends PlatformNotification.Builder<PcNotification, Builder> {
        private String title;

        protected Builder getThis() {
            return this;
        }

        public Builder setTitle(String title) {
            this.title = title;
            return this;
        }


        public Builder setAlert(Object alert) {
            this.alert = alert;
            return this;
        }

        public PcNotification build() {
            return new PcNotification(alert, title, extrasBuilder, numberExtrasBuilder, booleanExtrasBuilder,
                    jsonExtrasBuilder);
        }
    }
}

